package com.sikao.app.ui;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sikao.app.R;
import com.sikao.app.ui.base.BaseActivity;
import com.sikao.app.utils.SizeConvertUtils;

public class SellerOrderScheduleActivity extends BaseActivity implements View.OnClickListener{

	private TextView titleTv;
	private ImageView backIv;
	private ImageView iv1;
	private ImageView iv2;
	private ImageView iv3;
	private ImageView iv4;
	private ImageView iv5;
	private ImageView iv6;
	private ImageView iv7;
	private ImageView iv8;
	private ImageView iv9;
	private TextView tv1;
	private TextView tv2;
	private TextView tv3;
	private TextView tv4;
	private TextView tv5;
	private TextView tv6;
	private TextView tv7;
	private TextView tv8;
	private TextView tv9;
	private int size;
	private int schedule;//进度

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_seller_order_schedule);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void initData() {
		schedule = getIntent().getIntExtra("schedule",0);
	}

	@Override
	protected void initView() {
		titleTv = (TextView) findViewById(R.id.title_middle_tv);
		backIv = (ImageView) findViewById(R.id.title_left_img);
		iv1 = (ImageView) findViewById(R.id.iv1);
		iv2 = (ImageView) findViewById(R.id.iv2);
		iv3 = (ImageView) findViewById(R.id.iv3);
		iv4 = (ImageView) findViewById(R.id.iv4);
		iv5 = (ImageView) findViewById(R.id.iv5);
		iv6 = (ImageView) findViewById(R.id.iv6);
		iv7 = (ImageView) findViewById(R.id.iv7);
		iv8 = (ImageView) findViewById(R.id.iv8);
		iv9 = (ImageView) findViewById(R.id.iv9);
		tv1 = (TextView) findViewById(R.id.tv1);
		tv2 = (TextView) findViewById(R.id.tv2);
		tv3 = (TextView) findViewById(R.id.tv3);
		tv4 = (TextView) findViewById(R.id.tv4);
		tv5 = (TextView) findViewById(R.id.tv5);
		tv6 = (TextView) findViewById(R.id.tv6);
		tv7 = (TextView) findViewById(R.id.tv7);
		tv8 = (TextView) findViewById(R.id.tv8);
		tv9 = (TextView) findViewById(R.id.tv9);
	}

	@Override
	protected void initListener() {
		backIv.setOnClickListener(this);
	}

	@Override
	protected void init() {
		titleTv.setText("进度");
		backIv.setVisibility(View.VISIBLE);
		size = SizeConvertUtils.dip2px(18);
		setOrderProgress(schedule);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.title_left_img:
				finish();
				break;
			default:
				break;
		}
	}

	private void setOrderProgress(int progress){
		switch (progress){
			case 0:
				setIvSize(iv1);
				tv1.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 1:
				setIvSize(iv2);
				tv2.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 2:
				setIvSize(iv3);
				tv3.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 3:
				setIvSize(iv4);
				tv4.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 4:
				setIvSize(iv5);
				tv5.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 5:
				setIvSize(iv6);
				tv6.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 6:
				setIvSize(iv7);
				tv7.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 7:
				setIvSize(iv8);
				tv8.setTextColor(getResources().getColor(R.color.text_red));
				break;
			case 8:
				setIvSize(iv9);
				tv9.setTextColor(getResources().getColor(R.color.text_red));
				break;
			default:
				break;
		}
	}

	private void setIvSize(ImageView iv){
		ViewGroup.LayoutParams ps = iv.getLayoutParams();
		ps.height = size;
		ps.width = size;
		iv.setLayoutParams(ps);
		iv.setImageResource(R.mipmap.icon_flow_red);
	}

}
